package VN.EDU.IMIC.DEVELOPER.TRANTHITHANHNGA.ARRAY.EX5;

public class Models {

	/**Revising Array
	 * @param int[] array
	 */
	public int [] revisingArray(int[]array){
		int count =0;
		int [] arr = new int[array.length];
		for(int i=array.length; i>=0; i--){
			arr[count] = array[i];
			count++;
		}
		return arr;
	}

	/** Bubbly sort
	 * @param int[]array
	 */
	public void bubblySort(int[]array){
		for(int i=0; i<array.length; i++){
			for(int j = i+1; j<=array.length -1; j++){
				if(array[i]>array[j]){
					int temp = array[i];
					array[i]=array[j];
					array[j]=temp;
				}
			}
		}
	}
	
	/** Insertion Sort
	 * @param int[]array
	 */
	public void insertionSort(double[]array){
		for (int i=0; i<array.length; i++){
			double currentElement = array[i];
			int k;
			for(k=i-1; k>=0&&array[k]> currentElement; k--){
				array[k+1]= array[k];		
				}
			array[k+1]= currentElement;
			}
		}
	}
